﻿namespace demo21_数组
{
    internal class Program
    {
        static void Main(string[] args)
        {

            //数组
            //一维数组
            //数组定义方式
            //1.声明      类型[] 数组名
            int[] arr1;
            string[] arr2;
            char[] arr3;

            //创建       new 类型[大小]
            arr1 = new int[10];
            arr2 = new string[10];


            //2.声明数组和创建数组
            int[] arr4 = new int[1];

            //3.数组声明的时候赋值 type [] arrayName = new type [size] {val1,val2,...,valn};
            int[] arr5 = new int[5] { 1, 2, 3, 4, 5 };

            //4.数组声明的时候赋值 type [] arrayName = new type [] {val1,val2,...,valn};
            int[] arr6 = new int[] { 1, 2, 3, 4, 5 };

            //5.type [] arrayName = {val1,val2,...,valn};
            int[] arr7 = { 1, 2, 3, 4, 5 };




            //数组访问 数组名[下标]
            int[] a = new int[5];
            a[0] = 10;
            Console.WriteLine(a[0]);
            Console.WriteLine(a[1]);

            //求数组最值
            int[] b = {1,2,3,4,5,6,7,8,9};
            int max = 0;
            int min = b[0];
            for(int i = 0;i < 9; i++)
            {
                if (b[i] > max)
                {
                    max = b[i];
                }
                if (b[i] < min)
                {
                    max = b[i];
                }
            }
            Console.WriteLine(max);
            Console.WriteLine(min);



        }
    }
}
